﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using System.Windows.Forms;


namespace TJADRICD.CollaborativeDesignPlugin
{


    public class VersionInfo
    {
        public VersionInfo()
        {
            date = "";
            descriptionChinese = "";
            descriptionEnglish = "";
        }

        public int version;
        public string date;
        public string descriptionChinese;
        public string descriptionEnglish;
    }

    public class VersionList
    {

        public Dictionary<int, VersionInfo> versionList = new Dictionary<int, VersionInfo>();

        public void LoadFromAttribute(List<AttributeReference> attrRefs)
        {
            foreach (AttributeReference attrRef in attrRefs)
            {
                if (attrRef.Tag.StartsWith("Date"))
                {
                    int n = CommandFrame.VersionStrToInt(attrRef.Tag.Substring("Date".Length, attrRef.Tag.Length - "Date".Length)) - 1;
                    if (!(versionList.ContainsKey(n)))
                    {
                        versionList.Add(n, new VersionInfo());
                    }
                    string tmp = attrRef.TextString;
                    versionList[n].date = tmp;
                }
                else if (attrRef.Tag.StartsWith("DescriptionChinese"))
                {
                    int n = CommandFrame.VersionStrToInt(attrRef.Tag.Substring("DescriptionChinese".Length, attrRef.Tag.Length - "DescriptionChinese".Length)) - 1;
                    if (!(versionList.ContainsKey(n)))
                    {
                        versionList.Add(n, new VersionInfo());
                    }
                    string tmp = attrRef.TextString;
                    versionList[n].descriptionChinese = tmp;
                }
                else if (attrRef.Tag.StartsWith("DescriptionEnglish"))
                {
                    int n = CommandFrame.VersionStrToInt(attrRef.Tag.Substring("DescriptionEnglish".Length, attrRef.Tag.Length - "DescriptionEnglish".Length)) - 1;
                    if (!(versionList.ContainsKey(n)))
                    {
                        versionList.Add(n, new VersionInfo());
                    }
                    string tmp = attrRef.TextString;
                    versionList[n].descriptionEnglish = tmp;
                }
            }
        }
    }
}
